<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<div class="add_none">
    <div id="password" class="easyui-window" title="修改密码" data-options="closed:true,collapsible:false,minimizable:false,modal:true,maximizable:false,footer:'#ft'" style="padding:15px; width:500px; height:auto">
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="table" >
      <tr>
        <td class="t30 tright">旧密码：</td>
        <td class="t70"><input id="old_pwd" class="easyui-textbox" type="password" name="name" style="width:100%; height:28px"></input></td>
      </tr>
      <tr>
        <td class="t30 tright">新密码：</td>
        <td class="t70"><input id="new_pwd" class="easyui-textbox" type="password" name="name" style="width:100%; height:28px"></input></td>
      </tr>
      <tr>
        <td class="t30 tright">再次输入新密码：</td>
        <td class="t70"><input id="sure_pwd" class="easyui-textbox" type="password" name="name" style="width:100%; height:28px"></input></td>
      </tr>
    </table>
    </div>
    <div id="ft" style="text-align:center; padding:5px 0">
        <a href="javascript:void(0);" onclick="changePssword()" class="btn btn-default"><i class="fa fa-save"></i>保存</a>
    </div>
    <script type="text/javascript">
  //修改密码
    function changePssword(){
    	//数据收集
    	var old_pwd = $("#old_pwd").textbox("getValue");
    	var new_pwd = $("#new_pwd").textbox("getValue");
    	var sure_pwd = $("#sure_pwd").textbox("getValue");
    	//校验
    	if(old_pwd==""||new_pwd==""||sure_pwd==""){
    		$.messager.alert("提示","请全部填写");
    	}else if(new_pwd!=sure_pwd){
    		$.messager.alert("提示","两次输入密码不一致");
    	}else{
    		$.ajax({
    			url:"user/updatePasswordByUserid.do",
    			type:"post",
    			data:{
    				userid:"${user.userid}",
    				password:old_pwd,
    				new_password:new_pwd
    			},
    			dataType:"json",
    			success:function(result){
    				if(result.status){
    					var old_pwd = $("#old_pwd").textbox("setValue","");
    			    	var new_pwd = $("#new_pwd").textbox("setValue","");
    			    	var sure_pwd = $("#sure_pwd").textbox("setValue","");
    			    	$('#password').window('close');
    					$.messager.alert("提示",result.message);
    				}else{
    					$.messager.alert("提示",result.message);
    				}
    			}
    		});
    	}
    }
    </script>
</div>